package com.jjw.route.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jjw.route.utils.PageUtils;
import com.jjw.route.utils.Query;

import com.jjw.route.dao.PplengthDao;
import com.jjw.route.entity.PplengthEntity;
import com.jjw.route.service.PplengthService;


@Service("pplengthService")
public class PplengthServiceImpl extends ServiceImpl<PplengthDao, PplengthEntity> implements PplengthService {
    @Autowired
    PplengthDao pplengthDao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<PplengthEntity> page = this.page(
                new Query<PplengthEntity>().getPage(params),
                new QueryWrapper<PplengthEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public int selectPpLength(int max, int min) {
        PplengthEntity pplengthEntity = pplengthDao.selectOne(new QueryWrapper<PplengthEntity>().eq("lpoi", min).eq("rpoi", max));
        if (pplengthEntity == null) return 0;
        return pplengthEntity.getDtime() / 60;
    }

}